'''
第一周作业 3.28
'''
# 利用循环输出四种九九乘法表效果
# 1 for in 循环
print(' '*22,'for循环九九乘法表',' '*23)
print('='*65)
for i in range(1,10):
    for j in range(9,0,-1):
        if i<j :                 #将乘法表想像成填满的情况，再选择需要显示的等式
            print(' '*6,end=' ')
        else:
            print('{}*{}={:<2}'.format(j, i, j*i), end=' ')
    print()
print('='*65)
for i in range(9,0,-1):
    for j in range(9,0,-1):
        if j>i :
            print(' '*6,end=' ')
        else:
            print('{}*{}={:<2}'.format(j,i,j*i), end=' ')
    print()
print('='*65)

# 2 while循环
print(' '*22,'while循环九九乘法表',' '*23)
print('='*65)
i = 1
while i<10:
    j = 9
    while j>0:
        if i<j :
            print(' '*6,end=' ')
        else:
            print('{}*{}={:<2}'.format(j, i, j*i), end=' ')
        j = j-1
    i = i+1
    print()
print('='*65)
i = 9
while i>0:
    j = 9
    while j>0:
        if j>i:
            print(' ' * 6, end=' ')
        else:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
        j = j-1
    i = i-1
    print()
print('='*65)
print()

# 第二种九九乘法口诀表
# 1 for in 循环
for i in range(1,10):
    for j in range(1,i+1):
        print('{}*{}={:<2}'.format(i,j,i*j),end=' ')
    print()
print('='*65)
for i in range(9,0,-1):
    for j in range(1,i+1):
        print('{}*{}={:<2}'.format(i,j,i*j),end=' ')
    print()
print('='*65)

# 2 while 循环
print('='*65)
i = 1
while i<10:
    j = 1
    while j<=i:
        print('{}*{}={:<2}'.format(i,j,i*j),end=' ')
        j = j+1
    i = i+1
    print()
print('='*65)
i = 9
while i>0:
    j = 1
    while j<=i:
        print('{}*{}={:<2}'.format(i, j, i * j), end=' ')
        j = j + 1
    i = i - 1
    print()
print('=' * 65)


